﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Web;
using System.Web.Mvc;
using LaxCraft.Domain;


namespace LaxCraft.Helpers
{
    public static class LaxCraftSession
    {
        public static User CurrentUser
        {
            get
            {
                var user = (User)HttpContext.Current.Session["CurrentUser"];
                if (user == null)
                {
                    user = new User() {Username = "anonymous"};
                    HttpContext.Current.Session["CurrentUser"] = user;
                }
                return user;
            }
            set
            {
                HttpContext.Current.Session["CurrentUser"] = value;
            }
        }

        public static string[] LevelTitles
        {
            get
            {
                var levels = (string[])HttpContext.Current.Session["LevelTitles"];
                if (levels == null)
                {
                    levels = ConfigurationManager.AppSettings["LevelTitles"].Split(",".ToCharArray());
                }
                return levels;
            }
            set
            {
                HttpContext.Current.Session["LevelTitles"] = value;
            }
        }
    }
}
